#coding=utf-8
from django.db import models

# Create your models here.
'''
联系人资料表
'''
class info(models.Model):
    fullname=models.CharField(max_length=20,verbose_name='姓名')
    sex=models.CharField(max_length=1,choices=(('F', '女士'), ('M', '先生')),verbose_name='性别',null=True)
    age=models.IntegerField(verbose_name='年龄',null=True)
    screenname=models.CharField(max_length=20,verbose_name='网名',null=True)
    source=models.ForeignKey('source',verbose_name='来源',null=True)
    account=models.CharField(max_length=50,verbose_name='网络帐号',null=True)
    homephone=models.CharField(max_length=20,verbose_name='家庭电话',null=True)
    officephone=models.CharField(max_length=20,verbose_name='办公电话',null=True)
    mobile=models.CharField(max_length=20,verbose_name='移动电话',null=True)
    fax=models.CharField(max_length=20,verbose_name='传真',null=True)
    email=models.EmailField(max_length=75,verbose_name='电子邮箱',null=True)
    unit=models.ForeignKey('unit',verbose_name='单位',null=True)
    type=models.ForeignKey('type',verbose_name='类型',null=True)
    address=models.CharField(max_length=100,verbose_name='联系地址',null=True)
    zipcode=models.CharField(max_length=10,verbose_name='邮编',null=True)
    ower=models.ForeignKey('users.users',verbose_name='业务员',null=True)
    def __unicode__(self):
        sex=(self.sex=='M') and u'先生' or u'女士'
        return u'%s %s'%(self.fullname,sex)
    class Meta:
        verbose_name = "客户"
        verbose_name_plural = "客户列表"
    
'''
客户分类
'''
class type(models.Model):
    name=models.CharField(max_length=20,verbose_name='类别')
    def __unicode__(self):
        return u'%s'%self.name
    class Meta:
        verbose_name = "客户分类"
        verbose_name_plural = "客户分类"
'''
客户单位
'''
class unit(models.Model):
    name=models.CharField(max_length=20,verbose_name='单位名称')
    description=models.TextField(verbose_name='单位介绍',null=True)
    officephone=models.CharField(max_length=20,verbose_name='办公电话')
    fax=models.CharField(max_length=20,verbose_name='传真号码',null=True)
    email=models.EmailField(max_length=75,verbose_name='电子邮箱',null=True)
    address=models.CharField(max_length=50,verbose_name='联系地址',null=True)
    zipcode=models.CharField(max_length=15,verbose_name='邮编',null=True)
    def __unicode__(self):
        return u'%s'%self.name
    class Meta:
        verbose_name = "客户单位"
        verbose_name_plural = "客户单位"
'''
客户来源
'''
class source(models.Model):
    name=models.CharField(max_length=20,verbose_name='来源')
    class Meta:
        verbose_name = "客户来源"
        verbose_name_plural = "客户来源"
    def __unicode__(self):
        return u'%s'%self.name